package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.ProZczx;
import com.huizu.project.service.IProZczxService;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 政策咨询Controller
 * 
 * @author zhangmx
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/project/prozczx")
public class ProZczxController extends BaseController
{
    @Autowired
    private IProZczxService proZczxService;

    /**
     * 查询政策咨询列表
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProZczx proZczx)
    {
        startPage();
        List<ProZczx> list = proZczxService.selectProZczxList(proZczx);
        return getDataTable(list);
    }

    /**
     * 查询政策咨询列表(无需登录)
     * @param proZczx
     * @return
     */
    @GetMapping("/listNoAccess")
    public TableDataInfo listNoAccess(ProZczx proZczx)
    {
        startPage();
        List<ProZczx> list = proZczxService.selectProZczxList(proZczx);
        return getDataTable(list);
    }

    /**
     * 导出政策咨询列表
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:export')")
    @Log(title = "政策咨询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProZczx proZczx)
    {
        List<ProZczx> list = proZczxService.selectProZczxList(proZczx);
        ExcelUtil<ProZczx> util = new ExcelUtil<ProZczx>(ProZczx.class);
        util.exportExcel(response, list, "政策咨询数据");
    }

    /**
     * 获取政策咨询详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(proZczxService.selectProZczxById(id));
    }

    /**
     * 新增政策咨询
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:add')")
    @Log(title = "政策咨询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProZczx proZczx)
    {
        return toAjax(proZczxService.insertProZczx(proZczx));
    }

    /**
     * 修改政策咨询
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:edit')")
    @Log(title = "政策咨询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProZczx proZczx)
    {
        return toAjax(proZczxService.updateProZczx(proZczx));
    }

    /**
     * 删除政策咨询
     */
    @PreAuthorize("@ss.hasPermi('project:prozczx:remove')")
    @Log(title = "政策咨询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(proZczxService.deleteProZczxByIds(ids));
    }
}
